//
//  WKPageCell.m
//  CosChat
//
//  Created by Mark on 15/4/27.
//  Copyright (c) 2015年 yq. All rights reserved.
//

#import "WKPageCell.h"
#import "BCStuffSecondTableCell.h"
#import "BCStuffThirdTableCell.h"
@interface WKPageCell ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic ,strong)UITableView *secondListTable;
@property (nonatomic ,strong)UITableView *thirdListTable;
@property (nonatomic ,assign)NSInteger chooseNum;
@end

@implementation WKPageCell
- (id)initWithIdentifier:(NSString *)identifier{
    if (self = [super init]) {
        _identifier = identifier;
        [self createView];
    }
    return self;
}
- (void)createView{
    self.secondListTable = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 82*wx, SCREEN_HEIGHT) style:UITableViewStylePlain];
    self.thirdListTable = [[UITableView alloc] initWithFrame:CGRectMake(82 * wx, 0, SCREEN_WIDTH - 82 *wx, SCREEN_HEIGHT) style:UITableViewStylePlain];
    self.secondListTable.delegate = self;
    self.secondListTable.dataSource = self;
    [self.secondListTable registerClass:[BCStuffSecondTableCell class] forCellReuseIdentifier:@"secondReuse"];
    self.secondListTable.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.secondListTable.backgroundColor = [UIColor colorWithRed:0.972  green:0.973  blue:0.972 alpha:1];
    self.thirdListTable.delegate = self;
    self.thirdListTable.dataSource = self;
    self.thirdListTable.backgroundColor = [UIColor colorWithRed:0.972  green:0.973  blue:0.972 alpha:1];
    self.backgroundColor = [UIColor colorWithRed:0.953  green:0.957  blue:0.961 alpha:1];
    self.thirdListTable.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.thirdListTable registerClass:[BCStuffThirdTableCell class] forCellReuseIdentifier:@"thirdReuse"];
    [self addSubview:self.secondListTable];
    [self addSubview:self.thirdListTable];
    _chooseNum = 0;
    
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (tableView == self.secondListTable) {
        return 8;
    }else
    {
        return 10;
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (tableView == self.secondListTable) {
        return 40;
    }else
    {
        return 102;
    }
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (tableView == self.secondListTable) {
        _chooseNum = indexPath.row;
        [self.secondListTable reloadData];
    }else{
        [self.thirdListTable reloadData];
    }
}

- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (tableView == self.secondListTable) {
        BCStuffSecondTableCell *cell = [tableView dequeueReusableCellWithIdentifier:@"secondReuse"];
        cell.title = @"二级品类";
        if (indexPath.row == _chooseNum) {
            cell.choosed = YES;
        }else{
            cell.choosed = NO;
        }
        return cell;

    }else   {
        BCStuffThirdTableCell *cell = [tableView dequeueReusableCellWithIdentifier:@"thirdReuse"];
        cell.name = @"培根 500g";
        cell.price = @"9.5元";
        cell.amount = @"1";
        
        return cell;

      
    }

}

@end
